home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_Tix.idb / usr / freeware / lib / tix4.1 / OldUtil.tcl.z / OldUtil.tcl
Encoding:
Text File  |  1999-01-26  |  5.4 KB  |  224 lines

  1. # OldUtil.tcl -
  2. #
  3. #    This is an undocumented file.
  4. #       Are these features used in Tix : NO.
  5. #       Should I use these features    : NO.
  6. #
  7. # Copyright (c) 1996, Expert Interface Technologies
  8. #
  9. # See the file "license.terms" for information on usage and redistribution
  10. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. #
  12.  
  13. proc setenv {name args} {
  14.     global env
  15.  
  16.     if {[llength $args] == 1} {
  17.         return [set env($name) [lindex $args 0]]
  18.     } else {
  19.         if {[info exists env($ename)] == 0} {
  20.             tkerror "Error in setenv: "
  21.                     "environment variable \"$name\" does not exist"
  22.         } else {
  23.             return $env($name)
  24.         }
  25.     }
  26. }
  27. #----------------------------------------------------------------------
  28. #
  29. #
  30. #           U T I L I T Y   F U N C T I O N S  F O R   T I X 
  31. #
  32. #
  33. #----------------------------------------------------------------------
  34.  
  35. # RESET THE STRING IN THE ENTRY
  36. proc tixSetEntry {entry string} {
  37.     set oldstate [lindex [$entry config -state] 4]
  38.     $entry config -state normal
  39.     $entry delete 0 end
  40.     $entry insert 0 $string
  41.     $entry config -state $oldstate
  42. }
  43.  
  44. # GET THE FIRST SELECTED ITEM IN A LIST
  45. proc tixListGetSingle {lst} {
  46.     set indices [$lst curselection]
  47.     if {$indices != "" } {
  48.     return [$lst get [lindex $indices 0]]
  49.     } else {
  50.     return ""
  51.     }
  52. }
  53.  
  54. #----------------------------------------------------------------------
  55. # RECORD A DIALOG'S POSITION AND RESTORE IT THE NEXT TIME IT IS OPENED
  56. #----------------------------------------------------------------------
  57. proc tixDialogRestore {w {flag -geometry}} {
  58.     global tixDPos
  59.  
  60.     if [info exists tixDPos($w)] {
  61.     if ![winfo ismapped $w] {
  62.         wm geometry $w $tixDPos($w)
  63.         wm deiconify $w
  64.     }
  65.     } elseif {$flag == "-geometry"} {
  66.     update
  67.     set tixDPos($w) [winfo geometry $w]
  68.     } else {
  69.     update
  70.     set tixDPos($w) +[winfo rootx $w]+[winfo rooty $w]
  71.     }
  72. }
  73. #----------------------------------------------------------------------
  74. # RECORD A DIALOG'S POSITION AND RESTORE IT THE NEXT TIME IT IS OPENED
  75. #----------------------------------------------------------------------
  76. proc tixDialogWithdraw {w {flag -geometry}} {
  77.     global tixDPos
  78.  
  79.     if [winfo ismapped $w] {
  80.     if {$flag == "-geometry"} {
  81.         set tixDPos($w) [winfo geometry $w]
  82.     } else {
  83.         set tixDPos($w) +[winfo rootx $w]+[winfo rooty $w]
  84.     }
  85.     wm withdraw $w
  86.     }
  87. }
  88. #----------------------------------------------------------------------
  89. # RECORD A DIALOG'S POSITION AND RESTORE IT THE NEXT TIME IT IS OPENED
  90. #----------------------------------------------------------------------
  91. proc tixDialogDestroy {w {flag -geometry}} {
  92.     global tixDPos
  93.  
  94.     if [winfo ismapped $w] {
  95.     if {$flag == "-geometry"} {
  96.         set tixDPos($w) [winfo geometry $w]
  97.     } else {
  98.         set tixDPos($w) +[winfo rootx $w]+[winfo rooty $w]
  99.     }
  100.     }
  101.     destroy $w
  102. }
  103.  
  104. # Obsolete
  105. #
  106. proc tixQueryAppResource {name class default} {
  107.  
  108.     set value [option get . $name $class]
  109.     if {$value == ""} {
  110.     return $default
  111.     } else {
  112.     return $value
  113.     }    
  114. }
  115. proc tixCreateToplevel {w {type -mapped}} {
  116.     upvar #0 $w data
  117.  
  118.     toplevel $w
  119.     wm minsize $w 0 0
  120.     if {$type == "-withdrawn"} {
  121.     wm withdraw $w
  122.     }
  123.  
  124.     bind $w <Destroy>    [bind Toplevel <Destroy>]
  125.     bind $w <Map>        [bind Toplevel <Map>]
  126.     bind $w <Unmap>      [bind Toplevel <Unmap>]
  127.     bind $w <Visibility> [bind Toplevel <Visibility>]
  128.     bind $w <Destroy>    "+_tixToplevelDestroy $w"
  129.     bind $w <Map>        "+_tixToplevelMap $w"
  130.     bind $w <Unmap>      "+_tixToplevelUnmap $w"
  131.     bind $w <Visibility> "+_tixToplevelVisibility $w"
  132. }
  133.  
  134. proc _tixToplevelDestroy {w} {
  135.     upvar #0 $w data
  136.  
  137.     unset data
  138. }
  139.  
  140. proc _tixToplevelUnmap {w} {
  141.     upvar #0 $w data
  142.  
  143.     foreach dlg $data(dialogs) {
  144.     set data($dlg,geom) [winfo geometry $dlg]
  145.     wm withdraw $dlg
  146.     }
  147. }
  148.  
  149. proc _tixToplevelMap {w} {
  150.     upvar #0 $w data
  151.  
  152.     foreach dlg $data(dialogs) {
  153.     wm geometry $dlg $data($dlg,geom)
  154.     wm deiconify $dlg
  155.     }
  156. }
  157.  
  158. proc _tixToplevelVisibility {w} {
  159.     upvar #0 $w data
  160.  
  161.     foreach dlg $data(dialogs) {
  162.     raise $dlg $w
  163.     }
  164. }
  165.  
  166. proc tixCreateDialogShell {w {type -mapped}} {
  167.     toplevel $w
  168.     set parent [winfo parent $w]
  169.     upvar #0 $parent data
  170.  
  171.     wm minsize $w 0 0
  172.     wm withdraw $w
  173.     update
  174.     mwm transfor $w [winfo parent $w]
  175.     lappend data(dialogs) $w
  176.     bind $w <Destroy> "_tixDialogDestroy $w"
  177.  
  178.     if {$type != "-withdrawn"} {
  179.     wm deiconify $w
  180.     }
  181. }
  182.  
  183. proc _tixDialogDestroy {w} {
  184.     set parent [winfo parent $w]
  185.     upvar #0 $parent data
  186.  
  187.     catch {unset $data($w,geom)}
  188. }
  189.  
  190.  
  191. proc _tixInitMainWindow {w} {
  192.     upvar #0 $w data
  193.  
  194.     set data(dialogs) ""
  195.  
  196.     bind $w <Destroy>    +[bind Toplevel <Destroy>]
  197.     bind $w <Map>        +[bind Toplevel <Map>]
  198.     bind $w <Unmap>      +[bind Toplevel <Unmap>]
  199.     bind $w <Visibility> +[bind Toplevel <Visibility>]
  200.     bind $w <Destroy>    "+_tixToplevelDestroy $w"
  201.     bind $w <Map>        "+_tixToplevelMap $w"
  202.     bind $w <Unmap>      "+_tixToplevelUnmap $w"
  203.     bind $w <Visibility> "+_tixToplevelVisibility $w"
  204. }
  205.  
  206. # The "mwm" command comes from tkmwm, a cousin package of Tix
  207. # If this wish does not support mwm, the following line prevent code
  208. # that uses "mwm" from breaking.
  209. #
  210. if {[info commands mwm] == ""} {
  211.     proc mwm {args} {}
  212. }
  213.  
  214. #----------------------------------------------------------------------
  215. # Automatically initialization call
  216. #----------------------------------------------------------------------
  217.  
  218. # This has been disabled
  219.  
  220. if 0 {
  221.     _tixInitMainWindow .
  222. }
  223.  
  224.